package com.onstar.cn.common.util;

import android.content.Context;

import java.io.InputStream;
import java.util.Properties;

/**
 * Assets 文件操作类
 *
 * @author 7828wc
 */
public class AssetsUtils {
    /**
     * 获取配置文件中配置的信息
     *
     * @param context
     * @return
     * @throws Exception
     */
    public static Properties loadConfigFromAssets(Context context) throws Exception {
        if (context == null) {
            return loadConfigFromAssets();
        }
        Properties pro = new Properties();
        InputStream inputStream = context.getAssets().open("config.properties");
        pro.load(inputStream);
        return pro;
    }

    public static Properties loadConfigFromAssets() throws Exception {
        Properties pro = new Properties();
        pro.load(AssetsUtils.class.getResourceAsStream("/assets/config.properties"));
        return pro;
    }

}
